package com.tiger.web.controller.transaction;
import com.tiger.common.annotation.Log;
import com.tiger.common.core.controller.BaseController;
import com.tiger.common.core.domain.AjaxResult;
import com.tiger.common.core.page.TableDataInfo;
import com.tiger.common.enums.BusinessType;
import com.tiger.transaction.domain.ProposalInfo;
import com.tiger.transaction.service.IProposalInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 【意见建议】Controller
 *
 * @author standard
 * @date 2022-09-20
 */
@Api(tags = "意见建议")
@RestController
@RequestMapping("/system/proposalInfo")
public class ProposalInfoController extends BaseController {
    @Autowired
    private IProposalInfoService proposalInfoService;

    /**
     * 查询【意见建议】列表
     */
    @ApiOperation(value = "查询【意见建议】列表")
    //@PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProposalInfo proposalInfo) {
        startPage();
        List<ProposalInfo> list = proposalInfoService.selectProposalInfoList(proposalInfo);
        return getDataTable(list);
    }


    /**
     * 获取【意见建议】详细信息
     */
    @ApiOperation(value = "获取【意见建议】列详细信息")
    //@PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(proposalInfoService.selectProposalInfoById(id));
    }

    /**
     * 新增【意见建议】
     */
    @ApiOperation(value = "新增【意见建议】")
    //@PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "【意见建议】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ProposalInfo proposalInfo) {
        return toAjax(proposalInfoService.insertProposalInfo(proposalInfo));
    }

    /**
     * 修改【意见建议】
     */
    @ApiOperation(value = "处理【意见建议】")
    //@PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "【意见建议】", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ProposalInfo proposalInfo) {
        return toAjax(proposalInfoService.updateProposalInfo(proposalInfo));
    }

    /**
     * 删除【意见建议】
     */
//    @ApiOperation(value = "删除【意见建议】")
    //@PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "【意见建议】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(proposalInfoService.deleteProposalInfoByIds(ids));
    }
}
